const { error_fun } = require("../app/constants/error-types");
const { API_message_500 } = require("../app/constants/messageAPI");


const handleMenuData = async (ctx, next) => {

    const userId = Number(ctx.params.userId);

    if (isNaN(userId)) {
        ctx.body = API_message_500("传递的参数错误");
        return error_fun(ctx, '接收的参数错误');
    }

    //传递userId
    ctx.userId = userId;
    await next();
}

module.exports = { handleMenuData }